<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%String basepath = request.getContextPath(); %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>导流器个人版登陆</title>
<link href="css/adminLoginStyle.css" rel='stylesheet' type='text/css' />
<script type="text/javascript" src="<%=basepath%>/js/jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="<%=basepath%>/js/jquery.md5.js"></script>
<script type="application/x-javascript">
addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); 
function hideURLbar(){ window.scrollTo(0,1); }
</script>
</head>
<body>
<script>$(document).ready(function(c) {
	$('.close').on('click', function(c){
		$('.login-form').fadeOut('slow', function(c){
	  		$('.login-form').remove();
		});
	});
});
</script>
 <!--SIGN UP-->
 <h1>LSH Admin Login</h1>
<div class="login-form">
	<div class="close"> </div>
		<div class="head-info">
			<label class="lbl-1"> </label>
			<label class="lbl-2"> </label>
			<label class="lbl-3"> </label>
		</div>
			<div class="clear"> </div>
	<div class="avtar">
		<img src="img/avtar.png" />
	</div>
		<form>
		<input type="text" class="text" id="userName" name="userName" value="username" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'username';}" >
		<div class="key">
		<input type="password" id="passWord" name="passWord" value="password"  onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'password';}">
		</div>
		<p id="msgBox" style="color:#dd3e3e;margin-bottom:1em"></p>
		</form>
	<div class="signin">
		<input type="submit" value="Login" onclick="login()">
	</div>
</div>
 <div class="copy-rights">
 	<p>Copyright &copy; 2017.语义(上海)信息科技有限公司  All rights reserved.<a target="_blank" href="http://www.usources.cn">欢迎访问</a></p>
 </div>
</body>
<script type="text/javascript">
	function login(){
		var userName = $("#userName").val();
		var passWord = $("#passWord").val();
		if(!userName || !passWord || userName == 'username' || passWord == 'password'){
			$("#msgBox").html("请输入完整!");
			return;
		}
		  $.ajax({
			     url: '<%=basepath%>/login',
			     type: 'POST',
			     data: {'userName':userName,'passWord':$.md5(passWord)},
			     async: false,
			     cache: false,
			     success: function (data) {
			    	 if(data == 1){
			    		 location.href="<%=basepath%>/index.jsp";
			    	 }else if(data == 0){
			 			$("#msgBox").html("参数有误,请输入完整!");
			    	 }else{
			 			$("#msgBox").html("账号或密码错误,请重新输入!");
			    	 }
			     },
			     error: function (data) {
			         console.log(data);
			    	 $("#msgBox").html("网络错误,请稍后重试!");
			     }  
			  });
	}
</script>
</html>